home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 05 - 1989 / 05.09 Sep 89 / MacApp Code / Plot - Nelson / UExtendedText.p < prev    next >
Encoding:
Text File  |  1989-04-12  |  3.5 KB  |  118 lines  |  [TEXT/MPS ]

  1. { T E x t e n d e d T e x t    C L A S S                                }
  2.  
  3. { This unit creates a class of TExtendedText that will take the input     }
  4. { of real numbers within a range of MaxLong to MinLong, filtering the    }
  5. { keyboard input for any non-valid keys.  This view can be read from a    }
  6. { "r" file.  See below for the additions you need to add to the view.r    }
  7. { file for the format. The easiest way to create this view is to         }
  8. { create a TNumberText in ViewEdit, deRez it, and make the changes to     }
  9. { agree with the resource format of TExtendedText.  I would suggest     }
  10. { overriding the IRES method and adding a field to your instance of     }
  11. { TExtendedText to reference the document so you can store data in the     }
  12. { document's fields.  Also, if you wish to have instantaneous feedback     }
  13. { on changed data, override the StopEdit method and get the data at that}
  14. { point with GetValue.                                                    }
  15.  
  16. {***********************************************************************}
  17. {*  REMINDER: REMEMBER TO SET UP THE DEPEDENCIES IN YOUR MAKE FILE TO  *}
  18. {*  ACCOUNT FOR THE USE OF THIS UNIT!                                  *}
  19. {***********************************************************************}
  20.  
  21.  
  22.  
  23. UNIT UExtendedText;
  24.  
  25. INTERFACE
  26.  
  27. USES
  28.         { • MacApp - this includes all of the things necessary from the MacApp Library }
  29.         UMacApp, 
  30.  
  31.         { • Building Blocks }
  32.         UDialog, UPrinting,
  33.  
  34.         { • Implementation Use }
  35.         SANE, ToolUtils, Fonts, Resources, Script, PickerIntf, Packages;
  36.  
  37.  
  38. CONST
  39.  
  40.     MaxPrec = 8;  { Maximum allowable decimal precision }
  41.                   { Change this if you need a larger    }
  42.                   { precision value.                    }
  43.                   
  44.     bReal               = - 100;  { Constants used in the global }
  45.     bSingle             = - 101;  { MyFieldToString procedure so }
  46.     bDouble             = - 102;  { that these types can be      }
  47.     bExtended           = - 103;  { displayed by the inspector.  }
  48.  
  49. TYPE
  50.  
  51.     ExtendedTextTemplatePtr = ^ExtendedTextTemplate;
  52.     ExtendedTextTemplate =    RECORD
  53.                                 minimum:        LongInt;
  54.                                 maximum:        LongInt;
  55.                                 prec:            Integer;
  56.                                 value:            str255;
  57.                             END;
  58.  
  59.     TExtendedText =    OBJECT (TEditText)
  60.  
  61.         fMinimum:        Extended;
  62.         fMaximum:        Extended;
  63.         fPrecision:     integer;
  64.         fValue:            str255;
  65.         
  66.    
  67.  
  68.     {$IFC qProceduralViews}
  69.     PROCEDURE TExtendedText.IExtendedText(itsSuperView: TView;
  70.                               itsLocation, itsSize: VPoint;
  71.                               itsMinimum, itsMaximum : Extended;
  72.                               itsPrecision: integer;
  73.                               itsValue : str255);
  74.     {$ENDC}
  75.  
  76.     {$IFC qTemplateViews}
  77.         PROCEDURE TExtendedText.IRes (itsDocument: TDocument;
  78.                                       itsSuperView: TView;
  79.                                       VAR itsParams: Ptr); OVERRIDE;
  80.     {$ENDC}
  81.  
  82.     {$IFC qWriteTemplates}
  83.         PROCEDURE TExtendedText.WRes (theResource: ViewRsrcHndl; VAR itsParams: Ptr); OVERRIDE;
  84.  
  85.         PROCEDURE TExtendedText.WriteRes (theResource: ViewRsrcHndl;
  86.                                              VAR itsParams: Ptr); OVERRIDE;
  87.     {$ENDC}
  88.  
  89.         FUNCTION  TExtendedText.NotNull: Boolean;
  90.         
  91.         FUNCTION  TExtendedText.GetValue: extended;
  92.  
  93.         PROCEDURE TExtendedText.SetValue (newValue: extended; redraw: BOOLEAN);
  94.  
  95.         FUNCTION  TExtendedText.Validate: LONGINT; OVERRIDE;
  96.         
  97.         Function TExtendedText.DoKeyCommand ( ch : char; aKeyCode: integer;
  98.                                               VAR info : eventInfo):TCommand;OVERRIDE;
  99.  
  100.     {$IFC qDebug}
  101.         PROCEDURE TExtendedText.Fields (PROCEDURE DoToField (fieldName: Str255;
  102.                                        fieldAddr: Ptr; fieldType: INTEGER));OVERRIDE;
  103.         PROCEDURE TExtendedText.Warning( ErrorNum : integer);
  104.         PROCEDURE TExtendedText.PrecWarning;
  105.  
  106.     {$ENDC}
  107.         END; {TExtendedText}
  108.         
  109. IMPLEMENTATION
  110.  
  111. {$I UExtendedText.inc1.p}
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.